﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports BusinessRule.IBusiness
Imports DatabaseAccess.IDAL
Imports System.Data
Imports BusinessRule.Common
Imports DatabaseAccess.DALFactory
Imports External.APICalling
Imports BusinessRule.DTO
Imports System.Configuration
Public Class uMES_JXContainerCardBusiness
    Implements uMES_JXContainerCardIBusiness

    Private dal As IOracleDAL = uMESDalContext.instance.GetDalObject()

    Public Function GetJoinContainerCardInfo(ByVal QueryCondition As System.Collections.Generic.Dictionary(Of String, String)) As DTO.uMESProcessResult Implements IBusiness.uMES_JXContainerCardIBusiness.GetJoinContainerCardInfo
        GetJoinContainerCardInfo = New uMESProcessResult()

        Dim productname = QueryCondition("productname")

        Dim sb = New StringBuilder()
        sb.AppendLine(" select pb.productname,nvl(w.workflowid,w1.workflowid)workflowid ,Nvl(wb.workflowname,wb1.workflowname)workflowname,")
        sb.AppendLine(" ws.workflowstepname,nvl(sb.specname,sb1.specname)specname, ws.sequence")
        sb.AppendLine(" from product p")
        sb.AppendLine(" left join productbase pb on pb.revofrcdid = p.productid")
        sb.AppendLine(" left join workflow w on w.workflowid = p.workflowid")
        sb.AppendLine(" left join workflowbase wb on wb.workflowbaseid = w.workflowbaseid")
        sb.AppendLine(" left join workflowbase wb1 on wb1.workflowbaseid = p.workflowbaseid")
        sb.AppendLine(" left join workflow w1 on w1.workflowid = wb1.revofrcdid")
        sb.AppendLine(" left join workflowstep ws on ws.workflowid = w.workflowid or ws.workflowid =w1.workflowid")
        sb.AppendLine(" left join specbase sb on sb.specbaseid = ws.specbaseid")
        sb.AppendLine(" left join spec s on s.specid = sb.revofrcdid")
        sb.AppendLine(" left join spec s1 on s1.specid = ws.specid")
        sb.AppendLine(" left join specbase sb1 on sb1.specbaseid = s1.specbaseid")
        sb.AppendLine(" where pb.productname='" + productname + "' order by ws.sequence")

        Dim DT = dal.GetMfgOrderList(sb.ToString())
        If DT.Rows.Count = 0 Then
            GetJoinContainerCardInfo.Result = False
            GetJoinContainerCardInfo.Message = "零件不存在"
        End If

        GetJoinContainerCardInfo.DBTable = DT
    End Function
End Class
